package com.project.advertisement.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.project.R;
import com.project.advertisement.dao.AdvertisementDao;
import com.project.advertisement.property.Properties;
import com.project.advertisement.util.Utility;

public class RegisterEmailContent extends Activity {
	private AdvertisementDao advertisementDao;
	private EditText txtEmailContent;
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register_email_content);
        txtEmailContent=(EditText) findViewById(R.id.txtEmailContent);
        advertisementDao=new AdvertisementDao(getApplicationContext(),Properties.databaseName, null, 1);
    }
	
	public void saveEmailContent(View view){
		String emailContent=txtEmailContent.getText().toString().trim();
		if (!Utility.validateTextBox(emailContent)){
			Utility.showErrorMessage( Properties.emailContentErrorMessage,
					RegisterEmailContent.this);
			return;
		}
		
		long rowId=advertisementDao.registerEmailContent(emailContent);
		if(rowId>0){
			Toast.makeText(getApplicationContext(), Properties.emailContentSuccessfullyRegisteredMessage, Toast.LENGTH_LONG).show();
			txtEmailContent.setText("");
		}
		

	
		
	}

}
